<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script>
</head>

<body>

    <header class="aui-bar aui-bar-nav">
        <a class="aui-pull-left" tapmode onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="syx_name"></div>
    </header>
    <div class="aui-bar-nav-d"></div>

    <div id="list">
      <div class="licai-buy-t">
          <dl>
              <dd>预期年化收益</dd>
              <dt>4.25%</dt>
          </dl>
          <ul>
              <li>
                  <p>100元</p>
                  起投金额
              </li>
              <li>
                  <p>7天、15天、30天</p>
                  投资周期
              </li>
          </ul>


    </div>
    </div>

    <div class="licai-buy-2">
        <p>标准说明</p>
        新手体验标准是金可贷为满足新用户体验需求，而推出的全新体验标，可以帮助新用户快速了解金可贷产品从购买到本息返还的整体流程。
    </div>
    <div class="licai-buy-2">
        <p>标准规则</p>
        <p>
        投资限制： 100元起投，最高限额1000元
       </p>
        计息方式： 购买后开始计息

        <p>
        返还方式： 到期后本息一次性返还
       </p>
        <p>
        资金安全： 金可贷平台所有资金由鄂托克前旗农行存管，用户均在鄂托克前旗农行存管系统开通独立的资金管理账户
       </p>

    </div>
    <ul class="aui-list aui-list-in user-list">
        <!-- <li class="aui-list-item aui-list-item-middle">
            <div class="aui-list-item-inner aui-list-item-arrow" onclick="chanpinxiangqing();">
                <div class="aui-list-item-title">产品详情</div>
            </div>
        </li> -->
        <li class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-arrow" onclick="more_ques();">
                <div class="aui-list-item-title">常见问题</div>
            </div>
        </li>
    </ul>
    <div class="licai-d-btn-t"></div>
    <div class="licai-d-btn" tapmode id="weidenglu" onclick="weidenglu();">请登录</div>
    <!-- <div class="licai-d-btn" tapmode id="weikaitong" style="display: none;" onclick="weikaitong();">请前往开通存管账户</div> -->
    <div class="licai-d-btn" tapmode id="kegoumai" onclick="syx_buy_details()" style="display: none;">立即购买</div>
</body>

<script type="text/template" id="template">
    <div class="licai-buy-t">
        <dl>
            <dd>预期年化收益</dd>
            <dt>{{=it.rate}}%</dt>
        </dl>
        <ul>

            <li>
                <p>{{=it.min_money_format_num}}元</p>
                起投金额
            </li>
            <li>
                <p>7天、15天、30天</p>
                投资周期
            </li>
        </ul>
    </div>

    <!-- <div class="licai-buy-1">
        <div class="licai-buy-1-t">
            <img src="image/licai-buy-1-t.png"> 周期收益
        </div>
        <ul class="licai-buy-1-1">
            <li>
                <span>购买成功</span>
                <img src="image/licai-buy-1-1.png">
                <p>{{=it.date_1}}</p>
            </li>
            <i></i>
            <li>
                <span>开始计息</span>
                <img src="image/licai-buy-1-2.png">
                <p>{{=it.date_2}}</p>
            </li>
            <i></i>
            <li>
                <span>收益到账</span>
                <img src="image/licai-buy-1-3.png">
                <p>{{=it.date_3}}</p>
            </li>
        </ul>
    </div> -->
</script>

<script type="text/javascript">
    // 进度条同步
    var licainum = $(".licai-buy-t-d-t").html();
    $(".licai-buy-t-d-t").css("left", licainum);
    $(".aui-progress-bar").css("width", licainum);

    var load_count = '';
    var min_money_format_num = '';
    var borrow_amount = '';
    var rate = '';
    var time_limit = '';
    var max_money = ''; // 传入购买页面的可购买最高金额判断依据

    apiready = function() {
        id = api.pageParam.id;
        load_list(id);
    }

    function syx_buy_details() {
        var delay = 0;
        if (api.systemType != 'ios') {
            // delay = 300;
        }

        api.openWin({
            name: 'syx_buy_details',
            url: './syx_buy_details.html',
            pageParam: {
                min_money_format_num: min_money_format_num, // 起投金额
                rate: rate, // 利率
                // time_limit:time_limit,  // 期限
                id: id, // id
                max_money: max_money, // 可投上限
                add_money: add_money // 加减金额数
            }
        });
    };

    function unlock(psd) {
      // pay();
      alert(1111);

    }

    function login() {
        var delay = 0;
        if (api.systemType != 'ios') {
            // delay = 300;
        }
        api.openWin({
            name: 'login',
            url: './login.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    };

    // 未登录
    function weidenglu() {
        api.openWin({
            name: 'login',
            url: './login.html',
            pageParam: {
                login: 'syx_buy'
            }
        });
    }

    function closeWin() {
        api.closeWin({});
    }

    // 加载列表
    function load_list(id) {

        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '努力加载中...',
            text: '先喝杯茶...',
            modal: false
        });

        api.ajax({
            url: webAddress + '/index.php?ctl=app_deal2&act=licai&id=' + id,
            method: 'get',
        }, function(ret, err) {

            if (ret) {

                if (ret.status == 0) {
                    alert(ret.info);
                } else {
                    // alert( JSON.stringify( ret ) );
                    // return;
                    api.hideProgress();

                    load_count = ret.load_count;
                    min_money_format_num = ret.min_money_format_num;
                    borrow_amount = ret.borrow_amount;
                    rate = ret.rate;
                    time_limit = ret.time_limit;
                    max_money = ret.max_money;
                    // alert(ret.add_money);
                    add_money = ret.add_money;
                    name = ret.name;
                    var num = ret.load_list;
                    updateList(ret, num.length, name);
                }
            } else {
                // alert( JSON.stringify( err ) );
                alert(err.msg);
                api.hideProgress();
                api.closeWin({});
            }
        });
    }

    // doT
    function updateList(data, num, name) {

        // alert($api.getStorage('userid'));
        // alert($api.getStorage('is_hrb'));

        if ($api.getStorage('userid') == null || $api.getStorage('userid') == '') {
            $('#weikaitong').hide();
            $('#kegoumai').hide();
            $('#weidenglu').show();
        } else {
               $('#kegoumai').show();

            // if (!$api.getStorage('is_hrb')) {
            //     $('#weidenglu').hide();
            //     $('#kegoumai').hide();
            //     $('#weikaitong').show();
            // } else {
            //     $('#weikaitong').hide();
            //     $('#weidenglu').hide();
            //     $('#kegoumai').show();
            // }
        }

        var template = $api.byId('template');
        var dotFn = doT.template(template.innerHTML);
        var html = dotFn(data);
        var list = $api.byId('list');
        $api.html(list, html);
        $(".money").each(function() {
            // alert($(this).text());
            var tmp = outputmoney($(this).text());
            $(this).text(tmp);
        });
        $('#syx_name').text(name);
        // $('#end_date').text(end_date);
        $('#end_date').text("T+1");
    }

    function more_ques() {

      api.openWin({
          name: 'more_ques',
          url: './more_ques.html',
          pageParam: {
              name: 'test'
          }
      });

    }

    function chanpinxiangqing() {

        api.openWin({
            name: 'licai-chanpinxiangqing',
            url: './licai-chanpinxiangqing.html',
            pageParam: {
                id: id
            }
        });
    }
</script>

</html>
